/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.edu.agh.student.logic.service;

import java.util.List;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.log.Log;
import pl.edu.agh.student.logic.dao.GenericDao;
import pl.edu.agh.student.model.AbstractEntity;

/**
 *
 * @author janburkot
 */
public abstract class GenericServiceImpl<T extends AbstractEntity>
        implements GenericService<T> {

    
    @Logger
    protected Log log;

    @SuppressWarnings("unchecked")
    protected GenericServiceImpl() {
    }

    /**
     * {@inheritDoc}
     */
    public final T find(final long id) {
        return getDao().find(id);
    }

    /**
     * {@inheritDoc}
     */
    private void save(final T entity) {
        getDao().saveOrUpdate(entity);
    }

    /**
     * {@inheritDoc}
     */
    public void saveOrUpdate(final T entity) {
        getDao().saveOrUpdate(entity);
    }

    public void delete(final T entity) {
        getDao().delete(entity);
    }

    public void refresh(T entity) {
        getDao().refresh(entity);
    }

    public List<T> getAll() {
        return getDao().findAll();
    }
    
    public abstract GenericDao<T>getDao();
}
